﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSL.Lexer
{
    public class Commands
    {
        public const string DECLARE_FUNCTION = "function";

        public const string IF = "if";
        public const string ELSEIF = "elseif";
        public const string ELSE = "else";

        public const string WHILE = "while";

        public const string FOR = "for";

        public const string FOREACH = "foreach";

        public const string END = "end";

        public const string COMMENT = "#";
    }

    public class GetValueTokenResult
    {
        public bool IsValueToken
        {
            get;
            set;
        }

        public dynamic Value
        {
            get;
            set;
        }
    }

    public class ParserConstants
    {
        /// <summary>
        /// List with all commands
        /// </summary>
        public static readonly string[] CommandList = new string[]
        { 
            Commands.IF, Commands.ELSEIF, Commands.ELSE,
            Commands.WHILE, Commands.FOR, Commands.FOREACH, Commands.END
        };

        /// <summary>
        /// List of chars, with wich a function could start
        /// </summary>
        public static readonly char[] FunctionBeginParameterChars = new char[]
        {
            'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
            '_'
        };

        /// <summary>
        /// Chars which are allowed in function or parameter names
        /// </summary>
        public static readonly char[] FunctionParameterChars = new char[] 
        {
            'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',            
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
            '_', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
        };

        /// <summary>
        /// Chars, which are part of <seealso cref="FunctionParameterChars"/> but not allowed at the beginning of a function or parameter
        /// </summary>
        public static readonly char[] NotBeginParameterChars = new char[] 
        {
            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
        };

        /// <summary>
        /// Chars which split into a new token
        /// </summary>
        public static readonly char[] TokenSeperator = new char[] 
        {
            ' ', '+', '-', '*', '/', '^', '.', '[', ']', ':', '>', '<', '=', '!', '{', '}', '\r', '\n', '(', ')', ',', ';'
        };

        public static readonly char[] ComplexToken = new char[] 
        {
            '"'
        };

        /// <summary>
        /// Chars which autocomplete a token, from > = would be >= as one token
        /// Every single char must be in the tokensepeator-list
        /// </summary>
        public static readonly string[] FollowingTokens = new string[]
        {
            ">=", "<=", "==", "!=", "\r\n", "\r\n>"
        };
    }
}
